<template>
  <div>
    <!-- 不知道什么时候能拿到max，因为是异步获取的：使用watch监听 -->
    <h5 class="mui-content-padded">限定最小值和最大值(1~9)</h5>
    <div class="mui-numbox" data-numbox-min="1" :data-numbox-max="max" style="height:25px;">
      <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
      <input
        id="test"
        class="mui-input-numbox"
        type="number"
        value="initcount"
        @change="countChanged"
        readonly
        ref="numbox"
      />
      <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
  </div>
</template>

<script>
import mui from "../../mui/dist/js/mui.js";
export default {
  data() {
    return {};
  },
  mounted() {
    //初始化数字选择框组件
    mui(".mui-numbox").numbox();
  },
  methods: {
    countChanged() {
      this.$store.commit("updateGoodsInfo", {
        id: this.goodsid,
        count: this.$refs.bumbox.value
      });
    }
  },
  props: ["initcount", "goodsid  "]
};
</script>

<style lang="scss" scoped>
</style>